<?php

/**
 * RacksController
 * 
 * @package Sgit 
 * @author Juan Manuel Martinez Carrillo
 * @copyright Juan Manuel Martinez Carrillo
 * @version 2012
 * @access public
 * @revision 17/02/2012 9:06:
 * 
 */



class RacksController extends Sgit_Controller_Action
{
    
    protected $_main_model = 'Racks';
    protected $_main_form = 'Racks';
    protected $_checkZona=TRUE;
    
    
    public function indexAction()
    {
        

        
        $id_sala = $this->_request->getParam('id_sala');
        $id_proyecto = $this->_request->getParam('id_proyecto');
        
        $filtros = new Sgit_Form_Filtros();
        $sala = new Sgit_Form_Element_Select_Salas('id_sala');
        $sala->setValue($anio);
        $filtros->addFormSelect($sala);
        $proyectos = new Sgit_Form_Element_Select_Proyectos('id_proyecto');
        $proyectos->setValue($id_proyecto);
        $filtros->addFormSelect($proyectos);
        $values = $this->_getFiltrosValues($filtros);
        $filtros->myRender();
        
        $values['id_zona']=$this->_idZona;
        $this->view->rows=$this->_model->default->getRacks($values);
        
        
        
        
    
    }
    
    public function fichaAction()
    {
        $id=$this->_getParam('id_rack');
        
        $this->view->rack=$this->_model->default->getRack($id);
    
    }
    
    
    
/*
    public function pdfAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);

        $pdf = new Sgit_Pdf('L');
        $pdf->setColumnas($this->_getXml());
        $pdf->SetTitle('Proyectos DC');
        $pdf->render($this->_rows(), $this->_controllerName);
    }

    public function excelAction()
    {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);

        $excel = new Sgit_Excel();
        $excel->setColumnas($this->_getXml());
        $excel->render($this->_rows(), $this->_controllerName);
    }
*/
    public function insertarAction()
    {
        $this->_insertar();
    }

    public function editarAction()
    {
        $this->_editar();
    }

    public function borrarAction()
    {
        $this->_borrar();
    }
    
    protected function _prepareValuesToDb()
    {
        $row = $this->_form->getValues();
        
        if(!$this->_id)
        {
            $row['id_zona'] = $this->_idZona;
        }
        
      
        return $row;
    }


    protected function _getFila($id)
    {
        $row = $this->_model->default->GetRack($id);
        return $row;
    }



}
